#!/usr/bin/env python3
# -*- coding:utf-8 -*-

import logging
from typing import Any

"""由中序和后序序列求先序遍历结果
输入格式: 第一行给出正整数N, 是数中节点的个数,
         随后两行每行给出N个整数, 分别对应后序和中序序列, 数字间使用空格分隔
输出格式: 一个列表, 表示先序遍历的结果
"""


class Node(object):
    """节点类
    包含数据域, 左孩子, 和右孩子
    """
    def __init__(self, mdata: Any = None, lchild=None, rchild=None):
        self.__data = mdata
        self.__lchild = lchild
        self.__rchild = rchild

    def get_data(self):
        return self.__data

    def set_data(self, mdata: Any):
        self.__data = mdata

    def set_lchild(self, lchild):
        self.__lchild = lchild

    def set_rchild(self, rchild):
        self.__rchild = rchild


def _input() -> list:
    n = int(input())
    aft_order = [int(i) for i in input().split(' ')]
    mid_order = [int(i) for i in input().split(' ')]
    return [aft_order, mid_order]


def get_preorder(aft: list, mid: list) -> list:
    # edit your code
    pass


if __name__ == "__main__":
    data = _input()
    res = get_preorder(data[0], data[1])
    print(res)
